/*!
 * \file error.c
 * \brief Fichier d'affichage des messages d'erreurs et des messages d'avertissements.
 * \author RUL Mathieu
 * \version 1.0
 * \date 08 juin 2011
 */
#include <stdio.h>
#include "error.h"

//! Forme imprimable des erreurs d'exécutions
const char * errors_names[]= {
    "NOERROR",
    "UNKNOWN",
    "ILLEGAL",
    "CONDITION",
    "immediate value forbidden",
    "SEGTEXT",
    "SEGDATA",
    "SEGSTACK"
};

//! Forme imprimable des codes d'avertissement
const char * warnings_names[]= {
	"HALT reached"
};

void error(Error err, unsigned addr) __attribute__((noreturn));

void error(Error err, unsigned addr) {
	if (err) {
		fprintf(stderr, "ERROR: %s at address 0x%x\n", errors_names[err], addr);	
		exit(EXIT_FAILURE);
	}
	exit(EXIT_SUCCESS);
}

void warning(Warning warn, unsigned addr) {
	fprintf(stderr, "WARNING: %s at address 0x%x\n", warnings_names[warn], addr);
}
